#ifndef BRANCHS_HPP_INCLUDED
#define BRANCHS_HPP_INCLUDED

#include "miscellaneous.h"
#include "image.h"
#include "morphology.h"
#include "core.h"
#include <iostream>
#include "rcdata.h"
#include "externtypes.h"

class PositionMap : public Image{
    public:

        Position **map;

        PositionMap(unsigned int height,unsigned int width);
        ~PositionMap();


        void setPosition(Position position,Position value);

        Position getPosition(Position position);

        Position getPosition(int xposition,int yposition);

        void invert();

        Image* convert(ImageType newtype,int option=0,unsigned int value=1);
};

Grey_Image* getNeighbourvalue(Binary_Image* img,Grey_Image* out=NULL);

class BranchLabellingOptions{
    public:
        unsigned int critical_distance;
        float superposition_threshold_direct;
        float superposition_threshold_opposite;
        float acute_threshold;
        float opposite_threshold;
        int stabilitycondition;

        BranchLabellingOptions();
};

class PreprocessingOption{
    public:
    enum ObjectType{
        NEURON,
        RETINAL_VESSELS
    } type;

    //neuron
    int erosionradius;
    int areafilter;


    //retinal
    int densitysamplex;
    int densitysampley;
    int circleradius;

    float preprocessing_scale;

    PreprocessingOption();

};



Grey_Image* branchlabelling(Position primaryseed,Grey_Image* neighbourvalue,Binary_Image* body,PositionMap *crossmap=NULL,RCData* rcdata=NULL,RCData* newrcdata=NULL,BranchLabellingOptions options=BranchLabellingOptions(),unsigned int firstlabel=6,Grey_Image* out=NULL,unsigned int* lastlabel=NULL);

void newlabelling(Binary_Image* seeds,Binary_Image* branchskel,Binary_Image* body,BranchLabellingOptions options=BranchLabellingOptions(),PositionMap *crossmap=NULL,RCData* rcdata=NULL,RCData* newrcdata=NULL,Grey_Image* labelled=NULL);

void preprocessing(Binary_Image* image,Binary_Image** skel, Binary_Image** seed, Binary_Image** body, PreprocessingOption options=PreprocessingOption());

#endif // BRANCHS_HPP_INCLUDED
